<?php

namespace App\Api\V1\Controllers;

use App\Http\Controllers\Controller;

class TestController extends Controller
{
    public function index()
    {
        $datetime = new \DateTime();
        $raw = '22. 11. 1968';
        $start = $datetime->createFromFormat('d. m. Y', $raw);
        
        // $token = 'Start date: ' . $start->format('Y-m-d') . "\n";
                // create a copy of $start and add one month and 6 days
        $end = clone $start;

        $end->add(new \DateInterval('P1M6D'));

        // $diff = $end->diff($start);
        // $token = 'Difference: ' . $diff->format('%m month, %d days (total: %a days)') . "\n";
        // Difference: 1 month, 6 days (total: 37 days)
                
        return response()->json([
            'status' => 'ok',
            'token' => $end
        ], 200);
    }
}